﻿// Decompiled with JetBrains decompiler
// Type: TaleWorlds.MountAndBlade.View.WeaponComponentViewExtensions
// Assembly: TaleWorlds.MountAndBlade.View, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: 61152EB8-513B-4D4A-8AC0-0D1465C6CF6C
// Assembly location: D:\steam\steamapps\common\Mount & Blade II Bannerlord\Modules\Native\bin\Win64_Shipping_Client\TaleWorlds.MountAndBlade.View.dll

using TaleWorlds.Core;
using TaleWorlds.DotNet;
using TaleWorlds.Engine;

#nullable disable
namespace TaleWorlds.MountAndBlade.View
{
  public static class WeaponComponentViewExtensions
  {
    public static MetaMesh GetFlyingMeshCopy(
      this WeaponComponentData weaponComponentData,
      ItemObject item)
    {
      if (item.WeaponDesign != (WeaponDesign) null)
      {
        if (!weaponComponentData.IsRangedWeapon || !weaponComponentData.IsConsumable)
          return (MetaMesh) null;
        MetaMesh weaponMesh = CraftedDataViewManager.GetCraftedDataView(item.WeaponDesign).WeaponMesh;
        return !((NativeObject) weaponMesh != (NativeObject) null) ? (MetaMesh) null : weaponMesh.CreateCopy();
      }
      return !string.IsNullOrEmpty(item.FlyingMeshName) ? MetaMesh.GetCopy(item.FlyingMeshName) : (MetaMesh) null;
    }

    public static MetaMesh GetFlyingMeshIfExists(
      this WeaponComponentData weaponComponentData,
      ItemObject item)
    {
      return item.WeaponDesign != (WeaponDesign) null && weaponComponentData.IsRangedWeapon && weaponComponentData.IsConsumable ? CraftedDataViewManager.GetCraftedDataView(item.WeaponDesign).WeaponMesh : (MetaMesh) null;
    }
  }
}
